const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const baseUrl = 'http://192.168.1.196:8080/';

const Timestamp = new Date().getTime();
module.exports = {
	lintOnSave: false,
	publicPath: './',
	productionSourceMap: false, // 生产打包时不输出map文件，增加打包速度
	configureWebpack: {
		resolve: {
			alias: {
				'@': path.resolve(__dirname, './src'),
				'@i': path.resolve(__dirname, './src/assets'),
			},
		},
		plugins: [
			new MiniCssExtractPlugin({
				// 修改打包后css文件名
				filename: `css/[name].${Timestamp}.css`,
				chunkFilename: `css/[name].${Timestamp}.css`,
			}),
		],
		output: {
			// 输出重构  打包编译后的 文件名称  【模块名称.版本号.时间戳】
			filename: `js/[name].${Timestamp}.js`,
			chunkFilename: `js/[name].${Timestamp}.js`,
		},
	},
	devServer: {
		port: 9888, // 端口
		client: {
			overlay: false,
		},
		proxy: {
			'/api': {
				target: baseUrl,
				changeOrigin: true,
				https: false,
				ws: true,
				pathRewrite: {
					'^/api': '/api',
				},
			},
		},
	},
};
